home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 4 / The Arsenal Files 4 (Arsenal Computer).ISO / clarion / disabl.exe / CONTA002.CLW < prev    next >
Text File  |  1995-01-04  |  9KB  |  253 lines

  1.                      MEMBER('CONTACTS.clw')       ! This is a MEMBER module
  2. UpdateProc PROCEDURE
  3.  
  4. LocalRequest         LONG,AUTO
  5. OriginalRequest      LONG,AUTO
  6. LocalResponse        LONG,AUTO
  7. WindowOpened         LONG
  8. WindowInitialized    LONG
  9. ForceRefresh         LONG,AUTO
  10. ActionMessage        CSTRING(40)
  11. RecordChanged        BYTE,AUTO
  12. SAV::CON:Record      STRING(SIZE(CON:Record))
  13. SAV::CON:Remarks     STRING(SIZE(CON:Remarks))
  14. FormWindow           WINDOW('Update Records...'),AT(10,2,305,170),FONT('Arial',10,,),CENTER,SYSTEM,GRAY,MDI
  15.                        ENTRY(@s4),AT(52,3,29,12),USE(CON:ID)
  16.                        ENTRY(@s20),AT(52,23,,),USE(CON:FirstName)
  17.                        ENTRY(@s20),AT(200,23,,),USE(CON:LastName)
  18.                        ENTRY(@s25),AT(52,42,,),USE(CON:Company)
  19.                        ENTRY(@s25),AT(52,62,,),USE(CON:Address1)
  20.                        ENTRY(@s25),AT(52,83,,),USE(CON:Address2)
  21.                        ENTRY(@s2),AT(209,83,,),USE(CON:State)
  22.                        ENTRY(@s5),AT(259,83,,),USE(CON:Zip)
  23.                        ENTRY(@s25),AT(52,102,,),USE(CON:City)
  24.                        ENTRY(@p##/##/##p),AT(235,103,,),MSG('Date lead was received'),USE(CON:DateLead),OVR
  25.                        ENTRY(@p(###) ###-####p),AT(52,121,,),USE(CON:Phone)
  26.                        ENTRY(@p(###) ###-####p),AT(52,138,,),USE(CON:Fax)
  27.                        ENTRY(@s25),AT(157,121,,),USE(CON:JobTitle)
  28.                        TEXT,AT(157,138,56,12),MSG('Status of lead'),USE(CON:Status),CAP
  29.                        BUTTON('OK'),AT(28,155,40,12),USE(?OK),DEFAULT
  30.                        PROMPT('ID:'),AT(38,4,,),USE(?CON:ID:Prompt)
  31.                        PROMPT('&First Name:'),AT(5,24,,),USE(?CON:FirstName:Prompt)
  32.                        PROMPT('&Last Name:'),AT(154,24,,),USE(?CON:LastName:Prompt)
  33.                        PROMPT('&Company:'),AT(10,44,,),USE(?CON:Company:Prompt)
  34.                        PROMPT('Date of Lead:'),AT(185,105,,),USE(?CON:DateLead:Prompt)
  35.                        PROMPT('&Address 1:'),AT(8,64,,),USE(?CON:Address1:Prompt)
  36.                        PROMPT('&Address 2:'),AT(8,84,,),USE(?CON:Address2:Prompt)
  37.                        PROMPT('&Zip:'),AT(240,84,,),USE(?CON:Zip:Prompt)
  38.                        PROMPT('&State:'),AT(183,84,,),USE(?CON:State:Prompt)
  39.                        PROMPT('&City:'),AT(28,104,,),USE(?CON:City:Prompt)
  40.                        PROMPT('&Job Title:'),AT(119,124,,),USE(?CON:JobTitle:Prompt)
  41.                        PROMPT('&Phone:'),AT(20,124,,),USE(?CON:Phone:Prompt)
  42.                        PROMPT('&Fax:'),AT(28,138,,),USE(?CON:Fax:Prompt)
  43.                        PROMPT('Status:'),AT(126,139,25,10),USE(?CON:Status:Prompt)
  44.                        BUTTON('Cancel'),AT(73,155,40,12),USE(?Cancel)
  45.                        STRING(@S40),AT(118,155,,),USE(ActionMessage)
  46.                      END
  47.   CODE
  48.   LocalRequest = GlobalRequest
  49.   OriginalRequest = GlobalRequest
  50.   LocalResponse = RequestCancelled
  51.   CLEAR(GlobalRequest)
  52.   CLEAR(GlobalResponse)
  53.   SAV::CON:Record = CON:Record
  54.   SAV::CON:Remarks = CON:Remarks
  55.   IF LocalRequest = InsertRecord
  56.     DO PrimeFields
  57.   END
  58.   IF Status::Used = 0
  59.     CheckOpen(Status,1)
  60.   END
  61.   Status::Used += 1
  62.   IF contacts::Used = 0
  63.     CheckOpen(contacts,1)
  64.   END
  65.   contacts::Used += 1
  66.   OPEN(FormWindow)
  67.   WindowOpened=True
  68.   CASE LocalRequest
  69.   OF InsertRecord
  70.     ActionMessage = 'Record will be Added'
  71.   OF ChangeRecord
  72.     ActionMessage = 'Record will be Changed'
  73.   OF DeleteRecord
  74.     ActionMessage = 'Record will be Deleted'
  75.   END
  76.   ACCEPT
  77.     CASE EVENT()
  78.     OF EVENT:CloseWindow
  79.       IF LocalResponse <> RequestCompleted
  80.         RecordChanged = False
  81.         IF LocalRequest = InsertRecord OR LocalRequest = ChangeRecord
  82.           IF SAV::CON:Record <> CON:Record |
  83.           OR SAV::CON:Remarks <> CON:Remarks
  84.             RecordChanged = True
  85.           END
  86.         END
  87.         IF RecordChanged
  88.           CASE StandardWarning(Warn:ConfirmCancel)
  89.           OF Button:Yes
  90.             SELECT()
  91.             CYCLE
  92.           OF Button:No
  93.           OF BUTTON:Cancel
  94.             SELECT(?CON:ID)
  95.             CYCLE
  96.           END
  97.         END
  98.       END
  99.       DO RefreshWindow
  100.     OF EVENT:CloseDown
  101.       IF LocalResponse <> RequestCompleted
  102.         RecordChanged = False
  103.         IF LocalRequest = InsertRecord OR LocalRequest = ChangeRecord
  104.           IF SAV::CON:Record <> CON:Record |
  105.           OR SAV::CON:Remarks <> CON:Remarks
  106.             RecordChanged = True
  107.           END
  108.         END
  109.         IF RecordChanged
  110.           CASE StandardWarning(Warn:ConfirmCancel)
  111.           OF Button:Yes
  112.             LocalResponse = RequestCompleted
  113.             SELECT()
  114.             CYCLE
  115.           OF Button:No
  116.           OF BUTTON:Cancel
  117.             SELECT(?CON:ID)
  118.             CYCLE
  119.           END
  120.         END
  121.       END
  122.       DO RefreshWindow
  123.     OF EVENT:OpenWindow
  124.       IF NOT WindowInitialized
  125.         DO InitializeWindow
  126.       END
  127.       SELECT(?CON:ID)
  128.     OF EVENT:GainFocus
  129.       WindowInitialized = True
  130.       DO InitializeWindow
  131.     ELSE
  132.       IF EVENT() = Event:Completed
  133.         CASE LocalRequest
  134.         OF InsertRecord
  135.           ADD(contacts)
  136.           CASE ERRORCODE()
  137.           OF NoError
  138.             LocalResponse = RequestCompleted
  139.             POST(Event:CloseWindow)
  140.           OF DupKeyErr
  141.             IF DUPLICATE(CON:ID_Key)
  142.               IF StandardWarning(Warn:DuplicateKey,'CON:ID_Key')
  143.                 SELECT(?CON:ID)
  144.                 CYCLE
  145.               END
  146.             END
  147.           ELSE
  148.             IF StandardWarning(Warn:InsertError)
  149.               SELECT(?CON:ID)
  150.               CYCLE
  151.             END
  152.           END
  153.         OF ChangeRecord
  154.           LOOP
  155.             LocalResponse = RequestCancelled
  156.             SETCURSOR(Cursor:Wait)
  157.             IF RIUpdate:contacts(SAV::CON:Record)
  158.               SETCURSOR()
  159.               CASE StandardWarning(Warn:UpdateError)
  160.               OF Button:Yes
  161.                 CYCLE
  162.               OF Button:No
  163.                 POST(Event:CloseWindow)
  164.                 BREAK
  165.               OF Button:Cancel
  166.                 SELECT(?CON:ID)
  167.                 BREAK
  168.               END
  169.             ELSE
  170.               SETCURSOR()
  171.               LocalResponse = RequestCompleted
  172.               POST(Event:CloseWindow)
  173.             END
  174.             BREAK
  175.           END
  176.         OF DeleteRecord
  177.           LOOP
  178.             LocalResponse = RequestCancelled
  179.             SETCURSOR(Cursor:Wait)
  180.             IF RIDelete:contacts()
  181.               SETCURSOR()
  182.               CASE StandardWarning(Warn:DeleteError)
  183.               OF Button:Yes
  184.                 CYCLE
  185.               OF Button:No
  186.                 POST(Event:CloseWindow)
  187.                 BREAK
  188.               OF Button:Cancel
  189.                 SELECT(?CON:ID)
  190.                 BREAK
  191.               END
  192.             ELSE
  193.               SETCURSOR()
  194.               LocalResponse = RequestCompleted
  195.               POST(Event:CloseWindow)
  196.             END
  197.             BREAK
  198.           END
  199.         END
  200.       END
  201.     END
  202.     CASE FIELD()
  203.     OF ?OK
  204.       CASE EVENT()
  205.       OF EVENT:Accepted
  206.         DO SyncWindow
  207.         IF OriginalRequest = ChangeRecord OR OriginalRequest = InsertRecord
  208.           SELECT()
  209.         ELSE
  210.           POST(EVENT:Completed)
  211.         END
  212.         DO RefreshWindow
  213.       END
  214.     OF ?Cancel
  215.       CASE EVENT()
  216.       OF EVENT:Accepted
  217.         DO SyncWindow
  218.         LocalResponse = RequestCancelled
  219.         POST(Event:CloseWindow)
  220.         DO RefreshWindow
  221.       END
  222.     END
  223.   END
  224.   Status::Used -= 1
  225.   IF Status::Used = 0 THEN CLOSE(Status).
  226.   contacts::Used -= 1
  227.   IF contacts::Used = 0 THEN CLOSE(contacts).
  228.   IF WindowOpened
  229.     CLOSE(FormWindow)
  230.   END
  231.   IF LocalResponse
  232.     GlobalResponse = LocalResponse
  233.   ELSE
  234.     GlobalResponse = RequestCancelled
  235.   END
  236.   RETURN
  237. !---------------------------------------------------------------------------
  238. InitializeWindow ROUTINE
  239.   ForceRefresh = True
  240.   DO RefreshWindow
  241. !---------------------------------------------------------------------------
  242. RefreshWindow ROUTINE
  243.   DISPLAY()
  244.   ForceRefresh = False
  245. !---------------------------------------------------------------------------
  246. SyncWindow ROUTINE
  247. !---------------------------------------------------------------------------
  248. PrimeFields ROUTINE
  249.   CON:Record = SAV::CON:Record
  250.   CON:Remarks = SAV::CON:Remarks
  251.   SAV::CON:Record = CON:Record
  252.   SAV::CON:Remarks = CON:Remarks
  253.